/**
 * 系统平台
 * moonvip_admin
 * com.tz.web.diamondsidecalulation
 * DiamondSideCalulationController.java
 * 创建人:小胡
 * 时间：2017年03月04日 14:46:17
 *
 */
package com.tz.web.diamondsidecalulation;

import com.tz.auth.AuthPassport;
import com.tz.bean.DiamondSideCalulation;
import com.tz.bean.TzParams;
import com.tz.service.diamondsidecalulation.IDiamondSideCalulationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.HashMap;

/**
 * 副石估价管理web
 * DiamondSideCalulationController
 * 创建人:小胡
 * 时间：2017年03月04日 14:46:17
 * @version 1.0.0
 * 
 */
@Controller
@RequestMapping("/admin/service/diamondsidecalulation")
public class DiamondSideCalulationController {
	
	@Autowired
	private IDiamondSideCalulationService diamondsidecalulationService;

	/*列表查询*/
	@AuthPassport
	@RequestMapping("/list")
	public String list(TzParams params){
		return "service/diamondsidecalulation/list";
	}

    /*模板页面*/
	@RequestMapping("/template")
	public String template(TzParams params ,Model model){
		params.setDeleteCode("001");
		model.addAttribute("datas", diamondsidecalulationService.findDiamondSideCalulations(params));
		model.addAttribute("itemCount", diamondsidecalulationService.count(params));
		return "service/diamondsidecalulation/template";
	}

	@AuthPassport
	@RequestMapping("/add")
	public String add(TzParams params, Model model){
		model.addAttribute("qualitys",diamondsidecalulationService.getAllquality());
		return "service/diamondsidecalulation/add";
	}

	@AuthPassport
	@RequestMapping(value = "/edit/{id}" ,method = RequestMethod.GET)
	public String edit(@PathVariable("id") Integer id , Model model){
		HashMap<String ,Object> diamondsidecalulation = diamondsidecalulationService.getDiamondSideCalulation(id);
		model.addAttribute("diamondsidecalulation",diamondsidecalulation);
		model.addAttribute("qualitys",diamondsidecalulationService.getAllquality());
		return "service/diamondsidecalulation/edit";
	}

	@AuthPassport
	@ResponseBody
	@RequestMapping(value="/delete",method=RequestMethod.POST)
	public String delete(TzParams params){
		diamondsidecalulationService.delete(params);
		return "success";
	}


	@ResponseBody
	@RequestMapping(value="/update",method= RequestMethod.POST)
	public int update(DiamondSideCalulation diamondsidecalulation){
		diamondsidecalulation.setUpdateTime(new Date());
		int n = diamondsidecalulationService.update(diamondsidecalulation);
		return n;
	}

	@ResponseBody
	@RequestMapping(value="/save",method= RequestMethod.POST)
	public int save(DiamondSideCalulation diamondsidecalulation){
		int n = diamondsidecalulationService.save(diamondsidecalulation);
		return n;
	}






}
